package bishihuizong;

import javafx.util.Pair;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * Created by JiaJia on 2019/9/15 0015.
 */
public class Duxiaoman01 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            int startx=scanner.nextInt();
            int starty=scanner.nextInt();
            int n=scanner.nextInt();
            Queue<Pair<Integer,Integer>> queue=new LinkedList<>();
            while (n-->0){
                queue.add(new Pair<Integer, Integer>(scanner.nextInt(),scanner.nextInt()));
            }
            System.out.println(minpathLength(queue,startx,starty));
        }
    }
    public static int minpathLength(Queue queue,int tr,int tc){
        int[][] direction={{1,0},{-1,0},{0,1},{0,-1}};
        Queue<Pair<Integer,Integer>> queue2=new LinkedList<>();
        queue2.add(new Pair<>(0,0));
        int pathLength=0;
        while (!queue2.isEmpty()){
            int size=queue2.size();
            pathLength++;
            while (size-->0){
                Pair<Integer,Integer> cur=queue2.poll();
                int cr=cur.getKey(),cc=cur.getValue();
                queue.add(new Pair<>(cr,cc));
                for (int[] d:direction) {
                    boolean flag=true;
                    int nr=cr+d[0],nc=cc+d[1];
                    for (int i = 0; i <queue.size() ; i++) {
                        Pair<Integer,Integer> zhangai=(Pair<Integer,Integer>)queue.poll();
                        if (nr==zhangai.getKey()&&nc==zhangai.getValue()) {
                            flag = false;
                            //break;
                        }
                        queue.add(zhangai);
                    }
                    if (nr==tr&&nc==tc){
                        return pathLength;
                    }
                    if (flag) {
                        queue2.add(new Pair<Integer, Integer>(nr, nc));
                    }
                }
            }
        }
        return 0;
    }
}